package cn.bearspark.api.controller.main;

import cn.bearspark.api.service.main.TagService;
import cn.bearspark.api.vo.main.tag.TagVO;
import cn.bearspark.common.dto.Page;
import cn.bearspark.framework.web.starter.vo.ResponseVO;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 标签模块
 *
 * @author f
 */
@Validated
@RestController
@RequestMapping("/tag")
public class TagController {

    private final TagService tagService;

    public TagController(TagService tagService) {
        this.tagService = tagService;
    }

    /**
     * 条件分页获取标签信息
     *
     * @param keyword  关键字，可以为 null，表示查询所有标签信息
     * @param pageNum  标签的页数
     * @param pageSize 标签的条数
     * @return 标签的信息
     */
    @GetMapping
    public ResponseVO<Page<TagVO>> pageQuery(String keyword,
                                             @NotNull Integer pageNum,
                                             @NotNull Integer pageSize) {
        return ResponseVO.success(tagService.pageQuery(keyword, pageNum, pageSize));
    }

}
